define(function(require) {
    var loginSwicthMenu = require('module/DirectiveModule');

    loginSwicthMenu.directive('loginswitch', function() {
        return {
            scope: {},
            restrict: 'AE',
            controller: function($scope,$element, $location, $state, ngDialog) {
                var $contentDom = '<ul><li class="setting">' + $.i18n.text('manager_setting') + '</li><li class="logout">' + $.i18n.text('logout') + '</li></ul>';
                $($element).popover({
                    html: true,
                    toggle: 'popover',
                    trigger: 'focus',
                    placement: 'bottom',
                    title: '当前用户名称',
                    content: $contentDom
                }).on('shown.bs.popover', function() {
                    $('.popover').find('.setting').on('click', function() {
                        $state.go('index.Searching',{id: 'aaa',name:'ds'});
                    });
                    $('.popover').find('.logout').on('click', function() {
                        ngDialog.open({
                            template: 'src/scripts/template/LogoutDialog.html',
                            scope: $scope,
                            overlay: false
                        })
                    })
                });
            }
        }
    });
});